from django.shortcuts import render

# Create your views here.
from django.views import View

import logging

# /test/
from rest_framework.response import Response
from rest_framework.views import APIView


class TestView(View):
    def get(self, request):
        log = logging.getLogger('django')
        return render(request, 'test.html')


# /test2/
class TestView2(APIView):
    def get(self, request):
        # 解决跨域问题
        response = Response({'message': 'get 请求'})
        # response['Access-Control-Allow-Origin'] = 'http://127.0.0.1:8080'
        # 一个响应头可以添加多个值,但这里会出问题
        # response['Access-Control-Allow-Origin'] = 'http://www.meiduo.site:8080'
        return response

    def post(self, request):
        # 解决跨域问题
        response = Response({'message': 'post 请求'})
        # response['Access-Control-Allow-Origin'] = 'http://127.0.0.1:8080'
        # 一个响应头可以添加多个值
        # response['Access-Control-Allow-Origin'] = 'http://www.meiduo.site:8080'
        return response
